// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   VideoPanel.java

package presenter;

import java.awt.BorderLayout;
import java.awt.Component;
import java.io.File;
import java.net.URI;
import java.net.URL;
import javax.media.Manager;
import javax.media.Player;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class VideoPanel extends JPanel
{

    public VideoPanel(int x, int y)
    {
        setSize(x, y);
    }

    public void loadVideo(String s)
    {
        try
        {
            File file = new File(s);
            loadVideo(file.toURI().toURL());
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    public void loadVideo(URL url)
    {
        Manager.setHint(3, Boolean.valueOf(true));
        f = new File(url.getFile());
        try
        {
            player = Manager.createRealizedPlayer(url);
            video = player.getVisualComponent();
            setLayout(new BorderLayout());
            if(video != null)
                add(video, "Center");
            videoControls = player.getControlPanelComponent();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    public void start()
    {
        player.start();
    }

    public Component getVideo()
    {
        return player.getVisualComponent();
    }

    public Player getPlayer()
    {
        return player;
    }

    public String toString()
    {
        String name = f.toString();
        int beginExt = name.lastIndexOf(".");
        if(beginExt > 0)
            return name.substring(0, beginExt);
        else
            return name;
    }

    public Component getVideoControls()
    {
        return videoControls;
    }

    public static void main(String args[])
    {
        JFrame jf = new JFrame();
        VideoPanel vp = new VideoPanel(800, 600);
        jf.pack();
        vp.loadVideo("Imaginationland2.avi");
        vp.start();
        jf.setContentPane(vp);
        jf.setVisible(true);
        JFrame _tmp = jf;
        jf.setDefaultCloseOperation(2);
    }

    Component videoControls;
    Component video;
    Player player;
    File f;
}
